package com.thread;

/**
 * @Description
 * @Author zhoucq
 * @Date 2025/9/18 9:14
 * @Version 1.0
 */
public class MythreadStatus {
    public static void main(String[] args) throws InterruptedException {
        MyThreadExtendsThread thread = new MyThreadExtendsThread();

        //获取线程当前状态
        thread.getState();
        System.out.printf("线程的状态1" + thread.getState());
        thread.start();
        System.out.printf("线程的状态2" + thread.getState());
        //检查线程是否存活(非终止状态)
        thread.isAlive();
        System.out.printf("检查线程是否存活" + thread.isAlive());
        //主动让线程进入阻塞状态
        thread.sleep(1000);
        System.out.printf("线程的状态3" + thread.getState());
        //主动让出CPU，线程从运行→就绪
        thread.yield();
        System.out.printf("线程的状态4" + thread.getState());
    }
}
